package com.dkh.recommend.controller;

import com.dkh.recommend.dto.SaveCollectDTO;
import com.dkh.recommend.dto.Result;
import com.dkh.recommend.entity.TbCollect;
import com.dkh.recommend.entity.TbUserCollect;
import com.dkh.recommend.service.ITbCollectService;
import com.dkh.recommend.service.ITbUserCollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/collect")
@Api(value = "收藏夹", tags = "收藏夹-相关", description="收藏夹-相关")
public class CollectController {

    @Resource
    private ITbUserCollectService userCollectService;

    @Resource
    private ITbCollectService collectService;

//    todo 收藏夹

//   创建收藏夹
@ApiOperation("用户创建收藏夹")
@ApiImplicitParams({
        @ApiImplicitParam(name = "collectName", value = "收藏夹名字", required = true, dataType = "String", paramType = "param")})
@PostMapping("/create")
    public Result CreateCollect(@RequestParam String collectName){
        return userCollectService.CreateCollect(collectName);
    }

//     查看我的收藏夹列表
    @GetMapping("/mycollectlist")
    public Result MyCollectList(){
    return userCollectService.MyCollectList();
    }

    //    根据收藏夹id获取收藏夹歌单id列表
    @GetMapping("/getcollectmusicids/{collectId}")
    public Result GetCollectMusicIds(@PathVariable("collectId") Long collectId){
    return collectService.GetCollectMusicIds(collectId);
    }

//    根据收藏夹id获取收藏夹歌单总数

//    修改收藏夹名称
    @PutMapping("/updatecollectname")
    public Result UpdateCollectName(@RequestBody TbUserCollect userCollect){
    return userCollectService.UpdateCollectName(userCollect);
    }

//    删除收藏夹
    @DeleteMapping("/deletecollect")
    public Result deleteCollect(@RequestParam Long collectId){
    return userCollectService.deleteCollect(collectId);
    }

    //    将音乐加入收藏夹
    @PostMapping("/addmusic2collect")
    public Result AddMusic2Collect(@RequestBody TbCollect collect){
    return collectService.AddMusic2Collect(collect);
    }

    //    将音乐加入收藏夹
    @PostMapping("/add2music2collect")
    public Result Add2Music2Collect(@RequestBody SaveCollectDTO saveCollectDTO){
        return collectService.Add2Music2Collect(saveCollectDTO);
    }

    //    将音乐移出收藏夹
    @DeleteMapping("/deletemusic2collect")
    public Result DeleteMusic2Collect(@RequestBody TbCollect collect){
    return collectService.DeleteMusic2Collect(collect);
    }

    //    获取收藏夹音乐总数
    @GetMapping("/count/{collectId}")
    public Result countMusic2Collect(@PathVariable("collectId") String collectId){
    return collectService.countMusic2Collect(collectId);
    }


//    根据收藏夹Id获取收藏夹音乐列表
    @GetMapping("/getmsiculist/{collectId}")
    public Result getMyCollectMsicuListById(@PathVariable("collectId") String collectId){
    return collectService.getMyCollectMsicuListById(collectId);
    }


}
